home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / hMailServer / hMailServer-4.1-Build-136.exe / {app} / PHPWebAdmin / tools_restore.php < prev    next >
PHP Script  |  2005-04-05  |  20KB  |  550 lines

  1. <?php
  2. /*
  3. ** $Id: tools_restore.php,v 1.7 2005/04/05 11:05:20 hmailserver Exp $
  4. **
  5. **    hMailServer - Web interface
  6. **
  7. **    File formatted using TAB size 4
  8. **
  9. **    Get hMailserver at http://www.hmailserver.com
  10. **
  11. **    Author: Steen Rab°l <srabol@mail.tele.dk>
  12. **    Copyright (c) 2004, Steen Rab°l <srabol@mail.tele.dk>
  13. **
  14. **  This program is free software; you can redistribute it and/or modify
  15. **  it under the terms of the GNU General Public License as published by
  16. **  the Free Software Foundation; either version 2 of the License, or
  17. **  (at your option) any later version.
  18. **
  19. **  You may not change or alter any portion of this comment or credits
  20. **  of supporting developers from this source code or any supporting
  21. **  source code which is considered copyrighted (c) material of the
  22. **  original comment or credit authors.
  23. **
  24. **  This program is distributed in the hope that it will be useful,
  25. **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27. **  GNU General Public License for more details.
  28. **
  29. **  You should have received a copy of the GNU General Public License
  30. **  along with this program; if not, write to the Free Software
  31. **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  32. **
  33. */
  34.  
  35. if (!eregi("index.php", $_SERVER['PHP_SELF']))
  36. {
  37.     die ("You can't access this file directly...");
  38. }
  39.  
  40. if (hmailGetAdminLevel() != 2)
  41.     hmailHackingAttemp();
  42.  
  43.  
  44. require_once("include/minixml/minixml.inc.php");
  45. $function    = hmailGetVar("function");
  46.  
  47. if($function == "dorestore")
  48. {
  49.     $dodomains                = hmailGetVar("dodomains","");
  50.     $doaccounts                = hmailGetVar("doaccounts","");
  51.     $doaliases                = hmailGetVar("doaliases","");
  52.     $dodistributionlists    = hmailGetVar("dodistributionlists","");
  53.     $dodistrecipients        = hmailGetVar("dodistrecipients","");
  54.     $dosettings                = hmailGetVar("dosettings","");
  55.     $filename                = hmailGetVar("filename","");
  56.     $destfilename            = $hmail_config['temppath'] . $filename;
  57.     $output    = array();
  58.  
  59.     $xmlDoc = new MiniXMLDoc();
  60.     $xmlDoc->fromFile($destfilename);
  61.     $xmlRoot = &$xmlDoc->getRoot();
  62.  
  63.     if($dodomains == strtolower("on"))
  64.     {
  65.         $xmlroot_Domains = &$xmlRoot->getElement("domains");
  66.         if(is_object($xmlroot_Domains))
  67.         {
  68.             $restoreoptions = array();
  69.  
  70.             if($doaccounts == strtolower("on"))
  71.                 $restoreoptions["accounts"]    = true;
  72.             else
  73.                 $restoreoptions["accounts"]    = false;
  74.  
  75.             if($doaliases == strtolower("on"))
  76.                 $restoreoptions["aliases"]    = true;
  77.             else
  78.                 $restoreoptions["aliases"]    = false;
  79.  
  80.             if($dodistributionlists == strtolower("on"))
  81.                 $restoreoptions["distributionlists"]    = true;
  82.             else
  83.                 $restoreoptions["distributionlists"]    = false;
  84.  
  85.             if($dodistrecipients == strtolower("on"))
  86.                 $restoreoptions["distrecipients"]    = true;
  87.             else
  88.                 $restoreoptions["distrecipients"]    = false;
  89.  
  90.             RestoreDomains($xmlroot_Domains,$restoreoptions);
  91.         }
  92.         else
  93.         {
  94.             $output[]    = array("log"=>"Restore: Domains node not found in XML file '$filename'");
  95.         }
  96.     }
  97.  
  98.     if($dosettings == strtolower("on"))
  99.     {
  100.         $xmlroot_settings = &$xmlRoot->getElement("settings");
  101.         if(is_object($xmlroot_settings))
  102.         {
  103.             RestoreSettings($xmlroot_settings);
  104.         }
  105.     }
  106.     $hmailSmarty->assign("output",$output);
  107.     $hmailSmarty->assign("pagecontent",$hmailSmarty->fetch('tools_restore_complete.tpl'));
  108. }
  109. else if ($function == "dorestore_checkfile")
  110. {
  111.     $filename        = (isset($_REQUEST['filename']) ? $_REQUEST['filename'] : "");
  112.     $destfilename    = $hmail_config['temppath'] . $_FILES['filename']['name'];
  113.  
  114.     if (move_uploaded_file($_FILES['filename']['tmp_name'], $destfilename))
  115.     {
  116.         $xmlDoc = new MiniXMLDoc();
  117.         $xmlDoc->fromFile($destfilename);
  118.         $xmlRoot = &$xmlDoc->getRoot();
  119.  
  120.         $xmlroot_Domains = &$xmlRoot->getElement("domains");
  121.         if(is_object($xmlroot_Domains))
  122.         {
  123.             $hmailSmarty->assign("hasdomains",1);
  124.         }
  125.     
  126.         $xmlroot_Settings    = &$xmlRoot->getElement("settings");
  127.         if(is_object($xmlroot_Settings))
  128.         {
  129.             $hmailSmarty->assign("hassettings",1);
  130.         }
  131.         $hmailSmarty->assign("filename",$_FILES['filename']['name']);
  132.         $hmailSmarty->assign("pagecontent", $hmailSmarty->fetch('tools_restore_checkfile.tpl'));
  133.     }
  134.     else
  135.     {
  136.         $hmailSmarty->assign("error", hmailGetLocaleText("faild _to_upload_file"));
  137.         $hmailSmarty->assign("pagecontent", $hmailSmarty->fetch('tools_restore_checkfile.tpl'));
  138.     }
  139. }
  140. else
  141. {
  142.     $hmailSmarty->assign("pagecontent", $hmailSmarty->fetch('tools_restore.tpl'));
  143. }
  144.  
  145. function RestoreDomains(&$p_xmlroot,$p_options)
  146. {
  147.     global $obBaseApp;
  148.     AddToLog("Start restore, found " . $p_xmlroot->attribute("count") . " domains");
  149.     $xmldomains = &$p_xmlroot->getAllChildren();
  150.     if(is_array($xmldomains))
  151.     {
  152.         foreach($xmldomains as $xmldomain)
  153.         {
  154.             $xmldomain_name = &$xmldomain->getElement("name");
  155.             $domainname = trim($xmldomain_name->text());
  156.             AddToLog("Restore domain " . $xmldomain->attribute("id") . " '" . $domainname . "'" );
  157.             $obDomains    = $obBaseApp->Domains();
  158.             $obDomains->Refresh();
  159.             if(is_object($obDomains))
  160.             {
  161.                 $obDomain = @$obDomains->ItemByName($domainname);
  162.                 if(!$obDomain)
  163.                 {
  164.                     $obDomain    = $obDomains->Add();
  165.                     AddToLog("Create domain " . " " . $xmldomain_name->text());
  166.                 }
  167.                 else
  168.                 {
  169.                     AddToLog("Update domain " . " " . $xmldomain_name->text());
  170.                 }
  171.  
  172.                 $obDomain->Name    = $xmldomain_name->text();
  173.                 $xmldomain_active = &$xmldomain->getElement("active");
  174.                 $active = trim($xmldomain_active->text());
  175.                 if(empty($active) || $active == 0)
  176.                     $active    = false;
  177.                 else
  178.                     $active = true;
  179.  
  180.                 $obDomain->Active    = $active;
  181.  
  182.                 $xmldomain_postmaster = &$xmldomain->getElement("postmaster");
  183.                 $obDomain->Postmaster    = trim($xmldomain_postmaster->text());
  184.                 $obDomain->Save();
  185.                 $obDomains->Refresh();
  186.  
  187.                 if($p_options["accounts"])
  188.                 {
  189.                     $xmlaccounts    = &$xmldomain->getElement("accounts");
  190.                     if(is_object($xmlaccounts))
  191.                         RestoreAccounts($xmlaccounts,$obDomain,$p_options);
  192.                 }
  193.  
  194.                 if($p_options["aliases"])
  195.                 {
  196.                     $xmlaliases    = &$xmldomain->getElement("aliases");
  197.                     if(is_object($xmlaliases))
  198.                         RestoreAliases($xmlaliases,$obDomain);
  199.                 }
  200.  
  201.                 if($p_options["distributionlists"])
  202.                 {
  203.                     $xmldistributionlists    = &$xmldomain->getElement("distributionlists");
  204.                     if(is_object($xmldistributionlists))
  205.                         RestoreDistributionLists($xmldistributionlists,$obDomain,$p_options);
  206.                 }
  207.             }
  208.             else
  209.             {
  210.                 AddToLog("Faild to get Domain collection from server");
  211.             }
  212.         }
  213.     }
  214.     else
  215.     {
  216.         AddToLog("Faild to get domain information from file");
  217.     }
  218. }
  219.  
  220. function AddToLog($p_message)
  221. {
  222.     global $output;
  223.     $output[] = array("log" => $p_message);
  224. }
  225.  
  226. function RestoreAccounts(&$p_xmlroot, &$p_domain, &$p_options)
  227. {
  228.     $obAccounts    = $p_domain->Accounts();
  229.     AddToLog("Start restore, found " . $p_xmlroot->attribute("count") . " accounts");
  230.     $xmldaccounts = &$p_xmlroot->getAllChildren();
  231.     if(is_array($xmldaccounts))
  232.     {
  233.         foreach($xmldaccounts as $xmlaccount)
  234.         {
  235.             $xmlaccount_address_elm    = &$xmlaccount->getElement("address");
  236.             AddToLog("Restore account : " . $xmlaccount_address_elm->text());
  237.             $obAccount    = @$obAccounts->ItemByAddress(trim($xmlaccount_address_elm->text()));
  238.  
  239.             if(!$obAccount)
  240.                 $obAccount = $obAccounts->Add();
  241.  
  242.             $xmlaccount_active = &$xmlaccount->getElement("active");
  243.             $active = trim($xmlaccount_active->text());
  244.             if(empty($active) || $active == 0)
  245.                 $active    = false;
  246.             else
  247.                 $active = true;
  248.  
  249.             $obAccount->Active                    = $active;
  250.             $obAccount->Address                    = trim($xmlaccount_address_elm->text());
  251.             $xmlaccount_addomain_elm            = &$xmlaccount->getElement("addomain");
  252.             $obAccount->ADDomain                = $xmlaccount_addomain_elm->text();
  253.             $xmlaccount_isad_elm                = &$xmlaccount->getElement("isad");
  254.             $obAccount->IsAd                    = $xmlaccount_isad_elm->text() == "" ? 0 : 1;
  255.             $xmlaccount_password_elm            = &$xmlaccount->getElement("password");
  256.             $obaccount->Password                = $xmlaccount_password_elm->text();
  257.             $xmlaccount_adusername_elm            = &$xmlaccount->getElement("adusername");
  258.             $obAccount->ADUsername                = $xmlaccount_adusername_elm->text();
  259.             $xmlaccount_maxsize_elm                = &$xmlaccount->getElement("maxsize");
  260.             $obaccount->MaxSize                    = $xmlaccount_maxsize_elm->text();
  261.             $xmlaccount_vacationmessageison_elm    = &$xmlaccount->getElement("vacationmessageison");
  262.             $obAccount->VacationMessageIsOn        = $xmlaccount_vacationmessageison_elm->text() == "" ? 0 : 1;
  263.             $xmlaccount_vacationmessage_elm        = &$xmlaccount->getElement("vacationmessage");
  264.             $obAccount->VacationMessage            = $xmlaccount_vacationmessage_elm->text();
  265.             $xmlaccount_vacationsubject_elm        = &$xmlaccount->getElement("vacationsubject");
  266.             if($xmlaccount_vacationsubject_elm)
  267.             {
  268.                 $obAccount->VacationSubject            = $xmlaccount_vacationsubject_elm->text();
  269.             }
  270.             $obAccount->Save();
  271.  
  272.         }
  273.     }
  274.  
  275. }
  276. function RestoreAliases(&$p_xmlroot, &$p_domain)
  277. {
  278.     $xmlaliases = &$p_xmlroot->getAllChildren();
  279.     AddToLog("Restore aliases");
  280.     if(is_array($xmlaliases))
  281.     {
  282.         $obAliases    = $p_domain->Aliases();
  283.         foreach($xmlaliases as $xmlalias)
  284.         {
  285.             $elm = $xmlalias->getElement("name");
  286.             $obAlias = @$obAliases->ItemByName($elm->text());
  287.             if(!$obAlias)
  288.                 $obAlias = $obAliases->Add();
  289.  
  290.             $obAlias->Name        = $elm->text();
  291.             $elm = $xmlalias->getElement("active");
  292.             $obAlias->Active    = ($elm->text() == "" ? 0 : 1);
  293.             $obAlias->DomainID    = $p_domain->ID;
  294.             $elm = $xmlalias->getElement("type");
  295.             $obAlias->Type        = ($elm->text() == 0 ? 0 : $elm->text());
  296.             $elm = $xmlalias->getElement("value");
  297.             $obAlias->Value        = $elm->text();
  298.             $obAlias->Save();
  299.         }
  300.     }
  301. }
  302.  
  303. function RestoreDistributionLists(&$p_xmlroot,&$p_domain,$p_options)
  304. {
  305.     AddToLog("Restore distributionlists");
  306.     $xmldistributionlists = &$p_xmlroot->getAllChildren();
  307.     if(is_array($xmldistributionlists))
  308.     {
  309.         $obDistributionLists    = $p_domain->DistributionLists();
  310.         foreach($xmldistributionlists as $xmldistributionlist)
  311.         {
  312.             $elm = $xmldistributionlist->getElement("address");
  313.             $obDistributionList    = @$obDistributionLists->ItemByAddress($elm->text());
  314.             if(!$obDistributionList)
  315.                 $obDistributionList = $obDistributionLists->Add();
  316.  
  317.             $obDistributionList->Address    = $elm->text();
  318.             $elm = $xmldistributionlist->getElement("active");
  319.             $obDistributionList->Active = ($elm->text() == "" ? 0 : 1);
  320.             $elm = $xmldistributionlist->getElement("requiresmtpauth");
  321.             $obDistributionList->RequireSMTPAuth = ($elm->text() == "" ? 0 : 1);
  322.             $elm = $xmldistributionlist->getElement("requiresenderaddress");
  323.             $obDistributionList->RequireSenderAddress    = $elm->text();
  324.             $obDistributionList->Save();
  325.  
  326.             if($p_options["distrecipients"])
  327.             {
  328.                 $xmlrecip = $xmldistributionlist->getElement("recipients");
  329.                 if($xmlrecip)
  330.                 {
  331.                     if(is_object($xmlrecip))
  332.                     {
  333.                         $obRecipients = $obDistributionList->Recipients();
  334.                         $xmlrecipients = $xmlrecip->getAllChildren();
  335.  
  336.                         foreach($xmlrecipients as $xmlrecipient)
  337.                         {
  338.                             $obRecipient = $obRecipients->Add();
  339.                             $elm = $xmlrecipient->getElement("recipientaddress");
  340.                             $obRecipient->RecipientAddress = $elm->text();
  341.                             $obRecipient->Save();
  342.                         }
  343.                     }
  344.                 }
  345.             }
  346.         }
  347.     }
  348. }
  349.  
  350. function RestoreSettings($p_xmlroot)
  351. {
  352.     global $obBaseApp;
  353.     AddToLog("Restore settings");
  354.     $obSettings = $obBaseApp->Settings();
  355.     $xmlsettings = &$p_xmlroot;
  356.  
  357.     $elm = $xmlsettings->getElement("POP3Port");
  358.     $obSettings->POP3Port    = $elm->text();
  359.     $elm = $xmlsettings->getElement("SMTPPort");
  360.     $obSettings->SMTPPort    = $elm->text();
  361.     $elm = $xmlsettings->getElement("MaxSMTPConnections");
  362.     $obSettings->MaxSMTPConnections    = ($elm->text() == "" ? 0 : $elm->text());
  363.     $elm = $xmlsettings->getElement("MaxPOP3Connections");
  364.     $obSettings->MaxPOP3Connections    = ($elm->text() == "" ? 0 : $elm->text());
  365.     $elm = $xmlsettings->getElement("MirrorEMailAddress");
  366.     $obSettings->MirrorEMailAddress    = $elm->text();
  367.     $elm = $xmlsettings->getElement("AllowSMTPAuthPlain");
  368.     $obSettings->AllowSMTPAuthPlain    = ($elm->text() == "" ? 0 : $elm->text());
  369.     $elm = $xmlsettings->getElement("DenyMailFromNull");
  370.     $obSettings->DenyMailFromNull    = ($elm->text() == "" ? 0 : $elm->text());
  371.     $elm = $xmlsettings->getElement("TarpitDelay");
  372.     $obSettings->TarpitDelay    = $elm->text();
  373.     $elm = $xmlsettings->getElement("TarpitCount");
  374.     $obSettings->TarpitCount    = $elm->text();
  375.     $elm = $xmlsettings->getElement("SMTPNoOfTries");
  376.     $obSettings->SMTPNoOfTries    = $elm->text();
  377.     $elm = $xmlsettings->getElement("SMTPMinutesBetweenTry");
  378.     $obSettings->SMTPMinutesBetweenTry    = $elm->text();
  379.     $elm = $xmlsettings->getElement("IMAPPort");
  380.     $obSettings->IMAPPort    = $elm->text();
  381.     $elm = $xmlsettings->getElement("SMTPRelayer");
  382.     $obSettings->SMTPRelayer    = $elm->text();
  383.     $elm = $xmlsettings->getElement("WelcomeSMTP");
  384.     $obSettings->WelcomeSMTP    = $elm->text();
  385.     $elm = $xmlsettings->getElement("WelcomePOP3");
  386.     $obSettings->WelcomePOP3    = $elm->text();
  387.     $elm = $xmlsettings->getElement("WelcomeIMAP");
  388.     $obSettings->WelcomeIMAP    = $elm->text();
  389.     $elm = $xmlsettings->getElement("ServiceSMTP");
  390.     $obSettings->ServiceSMTP    = $elm->text();
  391.     $elm = $xmlsettings->getElement("ServicePOP3");
  392.     $obSettings->ServicePOP3    = $elm->text();
  393.     $elm = $xmlsettings->getElement("ServiceIMAP");
  394.     $obSettings->ServiceIMAP    = $elm->text();
  395.     $elm = $xmlsettings->getElement("MaxDeliveryThreads");
  396.     $obSettings->MaxDeliveryThreads    = $elm->text();
  397.     $elm = $xmlsettings->getElement("SendStatistics");
  398.     $obSettings->SendStatistics    = $elm->text();
  399.     $elm = $xmlsettings->getElement("HostName");
  400.     $obSettings->HostName    = $elm->text();
  401.     $elm = $xmlsettings->getElement("SMTPRelayerRequiresAuthentication");
  402.     $obSettings->SMTPRelayerRequiresAuthentication    = ($elm->text() == "" ? 0 : $elm->text());
  403.     $elm = $xmlsettings->getElement("SMTPRelayerUsername");
  404.     $obSettings->SMTPRelayerUsername    = $elm->text();
  405.     $elm = $xmlsettings->getElement("SMTPRelayerPort");
  406.     $obSettings->SMTPRelayerPort    = $elm->text();
  407.  
  408.     // Routes
  409.     $xmlroote_routes = $xmlsettings->getElement("routes");
  410.     if($xmlroote_routes)
  411.     {
  412.         AddToLog("Restore routes");
  413.         $xmlroutes    = &$xmlroote_routes->getAllChildren();
  414.         if(is_array($xmlroutes))
  415.         {
  416.             $obRoutes    = $obSettings->Routes();
  417.             foreach($xmlroutes as $xmlroute)
  418.             {
  419.                 $obRoute    = $obRoutes->Add();
  420.                 $elm = $xmlroute->getElement("DomainName");
  421.                 $obRoute->DomainName    = $elm->text();
  422.                 $elm = $xmlroute->getElement("TargetSMTPHost");
  423.                 $obRoute->TargetSMTPHost    = $elm->text();
  424.                 $elm = $xmlroute->getElement("TargetSMTPPort");
  425.                 $obRoute->TargetSMTPPort    = $elm->text();
  426.                 $elm = $xmlroute->getElement("NumberOfTries");
  427.                 $obRoute->NumberOfTries    = ($elm->text() == "" ? 0 : $elm->text());
  428.                 $elm = $xmlroute->getElement("MinutesBetweenTry");
  429.                 $obRoute->MinutesBetweenTry    = ($elm->text() == "" ? 0 : $elm->text());
  430.                 $elm = $xmlroute->getElement("AllAddresses");
  431.                 $obRoute->AllAddresses    = $elm->text();
  432.                 $elm = $xmlroute->getElement("RelayerRequiresAuth");
  433.                 $obRoute->RelayerRequiresAuth    = ($elm->text() == "" ? 0 : $elm->text());
  434.                 $elm = $xmlroute->getElement("RelayerAuthUsername");
  435.                 $obRoute->RelayerAuthUsername    = $elm->text();
  436.                 $elm = $xmlroute->getElement("TreatSecurityAsLocalDomain");
  437.                 $obRoute->TreatSecurityAsLocalDomain    = $elm->text();
  438.                 $obRoute->Save();
  439.  
  440.                 // Addresses
  441.                 $xmlroot_routes_adr = $xmlroute->getElement("routeaddresses");
  442.                 if($xmlroot_routes_adr)
  443.                 {
  444.                     $xmlroutesaddresses    = &$xmlroot_routes_adr->getAllChildren();
  445.                     if(is_array($xmlroutesaddresses))
  446.                     {
  447.                         $obAddresses = $obRoute->Addresses();
  448.                         foreach($xmlroutesaddresses as $xmlroutesaddress)
  449.                         {
  450.                             $obAddress = $obAddresses->Add();
  451.                             $elm = $xmlroutesaddress->getElement("Address");
  452.                             $obAddress->Address = $elm->text();
  453.                             $obAddress->RouteID    = $obRoute->ID;
  454.                             $obAddress->Save();
  455.                         }
  456.                     }
  457.                 }
  458.             }
  459.         }
  460.     }
  461.  
  462.     // IP Ranges
  463.     $xmlroot_ipranges = &$xmlsettings->getElement("ipranges");
  464.     if($xmlroot_ipranges)
  465.     {
  466.         $xmlranges    = &$xmlroot_ipranges->getAllChildren();
  467.         if(is_array($xmlranges))
  468.         {
  469.             AddToLog("Restore IP Ranges");
  470.             $obSecurityRanges    = $obSettings->SecurityRanges();
  471.             foreach($xmlranges as $xmlrange)
  472.             {
  473.                 $obRange    = $obSecurityRanges->Add();
  474.                 $elm = $xmlrange->getElement("LowerIP");
  475.                 $obRange->LowerIP = $elm->text();
  476.                 $elm = $xmlrange->getElement("UpperIP");
  477.                 $obRange->UpperIP = $elm->text();
  478.                 $elm = $xmlrange->getElement("AllowSMTPConnections");
  479.                 $obRange->AllowSMTPConnections = $elm->text();
  480.                 $elm = $xmlrange->getElement("AllowPOP3Connections");
  481.                 $obRange->AllowPOP3Connections = $elm->text();
  482.                 $elm = $xmlrange->getElement("Priority");
  483.                 $obRange->Priority = $elm->text();
  484.                 $elm = $xmlrange->getElement("AllowIMAPConnections");
  485.                 $obRange->AllowIMAPConnections = $elm->text();
  486.                 $elm = $xmlrange->getElement("Name");
  487.                 $obRange->Name = $elm->text();
  488.                 $elm = $xmlrange->getElement("RequireAuthForDeliveryToLocal");
  489.                 $obRange->RequireAuthForDeliveryToLocal = ($elm->text() == "" ? 0 : $elm->text());
  490.                 $elm = $xmlrange->getElement("RequireAuthForDeliveryToRemote");
  491.                 $obRange->RequireAuthForDeliveryToRemote = ($elm->text() == "" ? 0 : $elm->text());
  492.                 $elm = $xmlrange->getElement("AllowDeliveryFromLocalToLocal");
  493.                 $obRange->AllowDeliveryFromLocalToLocal = ($elm->text() == "" ? 0 : $elm->text());
  494.                 $elm = $xmlrange->getElement("AllowDeliveryFromLocalToRemote");
  495.                 $obRange->AllowDeliveryFromLocalToRemote = ($elm->text() == "" ? 0 : $elm->text());
  496.                 $elm = $xmlrange->getElement("AllowDeliveryFromRemoteToLocal");
  497.                 $obRange->AllowDeliveryFromRemoteToLocal = ($elm->text() == "" ? 0 : $elm->text());
  498.                 $elm = $xmlrange->getElement("AllowDeliveryFromRemoteToRemote");
  499.                 $obRange->AllowDeliveryFromRemoteToRemote = ($elm->text() == "" ? 0 : $elm->text());
  500.                 $obRange->Save();
  501.             }
  502.         }
  503.     }
  504.  
  505.     // Logging
  506.     $xmlroot_logging = &$xmlsettings->getElement("logging");
  507.     if($xmlroot_logging)
  508.     {
  509.         AddToLog("Restore logging");
  510.         $obLogging    = $obSettings->Logging();
  511.         $elm = $xmlroot_logging->getElement("Enabled");
  512.         $obLogging->Enabled    = ($elm->text() == "" ? 0 : $elm->text());
  513.         $elm = $xmlroot_logging->getElement("LogSMTP");
  514.         $obLogging->LogSMTP    = ($elm->text() == "" ? 0 : $elm->text());
  515.         $elm = $xmlroot_logging->getElement("LogPOP3");
  516.         $obLogging->LogPOP3    = ($elm->text() == "" ? 0 : $elm->text());
  517.         $elm = $xmlroot_logging->getElement("LogTCPIP");
  518.         $obLogging->LogTCPIP    = ($elm->text() == "" ? 0 : $elm->text());
  519.         $elm = $xmlroot_logging->getElement("LogApplication");
  520.         $obLogging->LogApplication    = ($elm->text() == "" ? 0 : $elm->text());
  521.         $elm = $xmlroot_logging->getElement("Device");
  522.         $obLogging->Device    = $elm->text();
  523.         $elm = $xmlroot_logging->getElement("LogFormat");
  524.         $obLogging->LogFormat    = $elm->text();
  525.         $elm = $xmlroot_logging->getElement("LogDebug");
  526.         $obLogging->LogDebug    = ($elm->text() == "" ? 0 : $elm->text());
  527.         $elm = $xmlroot_logging->getElement("LogIMAP");
  528.         $obLogging->LogIMAP    = ($elm->text() == "" ? 0 : $elm->text());
  529.     }
  530.     // Antivirus
  531.     $xmlroot_antivirus = &$xmlsettings->getElement("antivirus");
  532.     if($xmlroot_antivirus)
  533.     {
  534.         AddToLog("Restore antivirus");
  535.         $obAntivirus    = $obSettings->AntiVirus();
  536.         $elm = $xmlroot_antivirus->getElement("ClamWinEnabled");
  537.         $obAntivirus->ClamWinEnabled    = ($elm->text() == "" ? 0 : $elm->text());
  538.         $elm = $xmlroot_antivirus->getElement("ClamWinExecutable");
  539.         $obAntivirus->ClamWinExecutable    = $elm->text();
  540.         $elm = $xmlroot_antivirus->getElement("ClamWinDBFolder");
  541.         $obAntivirus->ClamWinDBFolder    = $elm->text();
  542.         $elm = $xmlroot_antivirus->getElement("Action");
  543.         $obAntivirus->Action    = ($elm->text() == "" ? 0 : $elm->text());
  544.         $elm = $xmlroot_antivirus->getElement("NotifyReceiver");
  545.         $obAntivirus->NotifyReceiver    = ($elm->text() == "" ? 0 : $elm->text());
  546.         $elm = $xmlroot_antivirus->getElement("NotifySender");
  547.         $obAntivirus->NotifySender    = ($elm->text() == "" ? 0 : $elm->text());
  548.     }
  549. }
  550. ?>